import time

from selenium.webdriver.common.by import By

from weixin_po.commom.BasePage import BasePage
from weixin_po.page_object.edit_page import editpage
from weixin_po.page_object.personnel_list import personnellist
from weixin_po.utils.log_util import logger


class Homepage(BasePage):
    _address_book = (By.XPATH, "//*[text()='通讯录']")
    _text_addmember = (By.XPATH, "//a[@class='qui_btn ww_btn js_add_member']")

    def click_add_member(self):
        """点击添加成员"""
        logger.info("点击添加成员")
        # 点击通讯录
        self.find(self._address_book).click()
        # 点击添加成员
        self.finds(self._text_addmember)[2].click()
        return editpage(self.driver)

    def click_list_member(self):
        """点击添加成员"""
        logger.info("点击通讯录")
        # 点击通讯录
        self.find(self._address_book).click()
        return personnellist(self.driver)
